package huanzhao.erp.domain.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import huanzhao.erp.domain.types.ExceptionType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

@TableName(value = "exception")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Exception implements Serializable {

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 申请人id
     */
    @TableField(value = "applicant_id")
    private Long applicantId;

    /**
     * 相关任务id
     */
    @TableField(value = "task_id")
    private Long taskId;

    /**
     * 审批人id
     */
    @TableField(value = "approver_id")
    private Long approverId;

    /**
     * 异常类型
     */
    @TableField(value = "type")
    private ExceptionType type;

    /**
     * 提交时间
     */
    @TableField(value = "submit_time")
    private Date submitTime;

    /**
     * 处理完成时间
     */
    @TableField(value = "finish_time")
    private Date finishTime;

    /**
     * 原因说明
     */
    @TableField(value = "reason")
    private String reason;

    /**
     * 丢失时间（类型为丢失时生效）
     */
    @TableField(value = "lost_time")
    private Date lostTime;

    /**
     * 是否通过
     */
    @TableField(value = "approve")
    private Boolean approve;

    /**
     * 处理意见
     */
    @TableField(value = "response")
    private String response;

    @Serial
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public Exception(Long applicantId, Long approverId, Long taskId, ExceptionType type, String reason,Date lostTime) {
        this.applicantId = applicantId;
        this.taskId = taskId;
        this.approverId = approverId;
        this.type = type;
        this.lostTime = lostTime;
        this.reason = reason;
    }
}